<?php

namespace App\Store\Validate\Order;

use App\Common\Validate\BaseValidate;

/**
 * 权限组验证器
 */
class OrderMaintenance extends BaseValidate
{

    //验证规则
    protected $rule = [];
    //自定义验证信息
    protected $message = [];


    public function __construct($doaction = 'add')
    {
        if ($doaction == 'add') {
            $this->rule = [
                // 'mobile' => ['required', 'regex:/^1[3-9]\d{9}$/'],
                'money'=>'required',
                'desc' => 'required',
            ];
            $this->message = [
                'mobile.required' => '手机号码不能为空',
                //'mobile.regex'=>'手机号码不规范',
                'money.required' => '定金金额不能为空',
                'money.integer' => '定金金额需大于0',
                'money.gt' => '定金金额需大于0',
                'desc.required' => '维修内容未填写',
            ];
        } elseif ($doaction == 'edit') {
            $this->rule = [
                'id' => 'required|integer|gt:0',
                'money'=>'required|integer|gt:0',
                'desc' => 'required',
            ];
            $this->message = [
                'id.required' => '参数错误',
                'id.integer' => '参数错误',
                'id.gt' => '参数错误',
                'money.required' => '定金金额不能为空',
                'money.integer' => '定金金额需大于0',
                'money.gt' => '定金金额需大于0',
                'desc.required' => '维修内容未填写',
            ];
        } elseif($doaction=='paytypecheck'){
            $this->rule=[
                'pay_money'=>'required|integer|gt:0',
                'pay_type_id'=>'required|integer',
            ];
            $this->message=[
                'pay_money.required' => '付款金额不能为空',
                'pay_money.integer' => '付款金额格式错误',
                'pay_money.gt' => '付款金额不能小于0',
                'pay_type_id.required' => '支付方式未选择',
                'pay_type_id.integer' => '支付参数错误',
            ];
        }
    }
}
